package com.ayu.scalalearn.chapter05

/**
  * @Author 徐林玉
  * @Description Recursion
  * @Date 2022/7/28 9:28
  * @Version 1.0
  */
object Test02Recursion {


  def main(args: Array[String]): Unit = {

    var sum =  factorial(5)

    println(sum)
  }

  def factorial(n: Int): Int = {
    //使用递归实现阶乘
    if (n == 0) {
      return 1
    }
    factorial(n - 1) * n
  }


}
